package com.sgb.kjwl.view.widget;

import android.content.Context;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.user.OrderPersonEntity;
import com.sgb.kjwl.view.ui.adapter.self.publish.OrderPersonAdapter;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

import java.util.List;

/**
 * 订单页跟单人
 */
public class OrderPersonWindow extends BasePopWindow {

    private OrderPersonAdapter adapter;
    private RecyclerView recyclerView;

    public OrderPersonWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_order_person;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        recyclerView = holder.getPop().findViewById(R.id.list);
        adapter = new OrderPersonAdapter(mContext, null);
        recyclerView.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerView.setAdapter(adapter);

        holder.getPop().findViewById(R.id.iv_down).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
    }

    public void setData(List<OrderPersonEntity> data) {
        adapter.setDatas(data);
        recyclerView.scrollToPosition(0);
    }
}
